home *** CD-ROM | disk | FTP | other *** search
- (*========================================================================*)
- (* AX25 Level 2 protocol *)
- (* *)
- (* Copyright 1986, 1987 by H. Roy Engehausen. All rights reserved. *)
- (* This software may be freely distributed and used, but it may not *)
- (* under any circumstances be sold by anyone other than the author. *)
- (* It may be distributed by a commercial company as long as it is *)
- (* for no cost. *)
- (* *)
- (*========================================================================*)
-
- CONST
- max_ax25_digipeaters = 8; (* Max digipeater count *)
-
- max_ax25_address = 11; (* Max addresses in ax25 header + 1 *)
- (* dest , source, 8 digis *)
-
- call_sign_length = 6; (* Length of the name section of addr *)
-
- address_field_length = 7; (* Length of the whole address field *)
-
- ssid_max = 15; (* Highest allowable ssid *)
-
- (*------------------------------------------------------------------------*)
- (* Address field. This is variable length. *)
- (*------------------------------------------------------------------------*)
-
- TYPE
-
- address_field = RECORD
- name : ARRAY[1..call_sign_length] of CHAR;
- addr_flag : BYTE;
- END;
-
- address_1 = RECORD (* This type is used for SIZEOF *)
- dest : address_field;
- source : address_field;
- END;
-
- address_area = RECORD
- dest : address_field;
- source : address_field;
- repeaters : ARRAY[1..max_ax25_digipeaters]
- OF address_field;
- END;
-
- call_field = ARRAY[1..call_sign_length] OF CHAR;
-
- address_over = ARRAY[1..max_ax25_address] OF address_field;
-
- address_area_ptr_type = ^address_area;
-
- (*------------------------------------------------------------------------*)
- (* Control byte *)
- (*------------------------------------------------------------------------*)
-
- TYPE
-
- control_field = BYTE;
-
- (*------------------------------------------------------------------------*)
- (* Protocol identification byte *)
- (*------------------------------------------------------------------------*)
-
- TYPE
-
- pid_field = BYTE;
-
- (*------------------------------------------------------------------------*)
- (* Data area *)
- (*------------------------------------------------------------------------*)
-
- TYPE
-
- data_field = ARRAY[1..512] OF CHAR;
-
- (*------------------------------------------------------------------------*)
- (* Combination of last three areas. They are always in this order *)
- (* and the same size *)
- (*------------------------------------------------------------------------*)
-
- TYPE
-
- packet_data = RECORD
- control_packet : control_field;
- pid_packet : pid_field;
- data_packet : data_field;
- END;
-
- (*------------------------------------------------------------------------*)
- (* Definition of addr_flag *)
- (* x....... = H flag (repeated -- only in digi addresses) *)
- (* x....... = C flag (Only in source and destination addresses) *)
- (* .xx..... = reserved (must be one) *)
- (* ...xxxx. = ssid *)
- (* .......x = E flag (end address) *)
- (*------------------------------------------------------------------------*)
-
- CONST
-
- flag_e = $01;
- flag_ssid = $1E;
- flag_reser = $60;
- flag_h = $80;
- flag_c = $80;
- flag_ssid_shift = 1; (* Shift factor for SSID *)
-
- (*------------------------------------------------------------------------*)
- (* Definition of control field *)
- (* *)
- (* .......0 = I frame *)
- (* ....xxx. = N(S) *)
- (* ...x ... = P/F *)
- (* xxx..... = N(R) *)
- (* *)
- (* ......01 = S frame *)
- (* ....0001 = RR *)
- (* ....0101 = RNR *)
- (* ....1001 = Reject *)
- (* ...x.... = P/F *)
- (* xxx..... = N(R) *)
- (* *)
- (* ......11 = U frame *)
- (* 000.0011 = Unnumbered information *)
- (* 000.1111 = DM (busy) *)
- (* 001.1111 = SABM *)
- (* 010.0011 = Disconnect *)
- (* 011.0011 = Unnumbered Ack *)
- (* 100.0111 = FRMR Frame reject *)
- (* ...x.... = P/F *)
- (*------------------------------------------------------------------------*)
-
- CONST
-
- control_su = $03; (* I/S/U frame bits *)
- control_if1 = $00; (* I frame *)
- control_if2 = $02; (* Also an I frame *)
- control_sf = $01; (* S frame *)
- control_uf = $03; (* U frame *)
-
- control_pf = $10; (* Mask for P/F *)
-
- control_ns = $0E; (* Mask for N(S) *)
- control_ns_shift = 1; (* Shift for N(S) *)
- control_nr = $E0; (* Mask for N(R) *)
- control_nr_shift = 5; (* Shift for N(R) *)
-
- control_sm = $0F; (* S frame mask *)
- control_rr = $01; (* S frame, RR *)
- control_rnr = $05; (* S frame, RNR *)
- control_rej = $09; (* S frame, Rejected *)
-
- control_um = $EF; (* U frame mask *)
- control_ui = $03; (* U frame, UI *)
- control_dm = $0F; (* U frame, DM *)
- control_sabm = $2F; (* U frame, SABM *)
- control_disc = $43; (* U frame, Disconnect *)
- control_ua = $63; (* U frame, Ack *)
- control_frmr = $87; (* U frame, FRMR *)
-
- (*------------------------------------------------------------------------*)
- (* Definition of protocol field *)
- (* *)
- (* These values are actually assigned *)
- (* *)
- (* 11001100 = Internet Protocol datagram layer 3 *)
- (* 11001101 = Address Resolution protocol layer 3 *)
- (* 11110000 = No layer 3 *)
- (* 11111111 = Next character has more information *)
- (* *)
- (* These are indicative of how this byte will be used in the future *)
- (* *)
- (* ..00.... = Reserved *)
- (* ..01.... = AX.25 Level 3 *)
- (* ..10.... = AX.25 Level 3 *)
- (* ..11.... = Reserved *)
- (*------------------------------------------------------------------------*)
-
- CONST
-
- protocol_ipd = $CC; (* Internet *)
- protocol_arp = $CD; (* Address resolution *)
- protocol_no3 = $F0; (* No layer 3 *)
- protocol_mor = $F0; (* No layer 3 *)
-
- protocol_kay = $30; (* Layer mask *)
- protocol_x30 = $00; (* ?????????? *)
- protocol_x31 = $10; (* AX level 3 *)
- protocol_x32 = $20; (* AX level 3 *)
- protocol_x33 = $30; (* ?????????? *)
-
- (*------------------------------------------------------------------------*)
- (* Definition of "C" field. This consists of the two "C" bits, one *)
- (* on the destination and one on the source. The equates below are *)
- (* for both bits in that order. *)
- (* *)
- (* 00 = Version 1 *)
- (* 01 = Version 2 Response *)
- (* 10 = Version 2 Command *)
- (* 11 = Version 1 *)
- (*------------------------------------------------------------------------*)
-
- CONST
-
- cfield_v11 = $00; (* Version 1 *)
- cfield_v2r = $01; (* Version 2 response *)
- cfield_v2c = $02; (* Version 1 command *)
- cfield_v12 = $03; (* Version 1 *)
-
- cfield_dm = $02; (* Destination Mask *)
- cfield_sm = $01; (* Source Mask *)
-
- (*------------------------------------------------------------------------*)
- (* State diagram for links *)
- (*------------------------------------------------------------------------*)
-
- TYPE
- link_state_type = (link_s1, (* Disconnected *)
- link_s2, (* Link setup *)
- link_s3, (* Frame reject *)
- link_s4, (* Disconnect request *)
- link_s5, (* Information transfer *)
- link_s6, (* REJ frame sent *)
- link_s7, (* Waiting ACK *)
- link_s8, (* Device busy *)
- link_s9, (* Remote device busy *)
- link_s10, (* Both devices busy *)
- link_s11, (* Waiting ACK and device busy *)
- link_s12, (* Waiting ACK and remote busy *)
- link_s13, (* Waiting ACK and both busy *)
- link_s14, (* REJ sent and device busy *)
- link_s15, (* REJ sent and remote busy *)
- link_s16); (* REJ sent and both busy *)
-